<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
	<title>jQuery plugin: Tablesorter 2.0 - Dealing with markup inside cells</title>

	<!-- jQuery -->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

	<!-- Demo stuff -->
	<link rel="stylesheet" href="css/jq.css">
	<link href="css/prettify.css" rel="stylesheet">
	<script src="js/prettify.js"></script>
	<script src="js/docs.js"></script>

	<!-- Tablesorter: required -->
	<link rel="stylesheet" href="../css/theme.blue.css">
	<script src="../js/jquery.tablesorter.js"></script>

	<script id="js">$(function() {

	// call the tablesorter plugin
	$("table").tablesorter({
		theme : 'blue',
		/*
		// define an overall custom text extraction function
		textExtraction: function(node, table, cellIndex) {
			return $(node).text();
		}
		*/

		// Define a custom text extraction function for each column
		// In this example, textExtraction 1-5 functions don't really need to
		// be defined, since they can also be obtained using `$(node).text()`
		textExtraction: {
			0: function(node, table, cellIndex){ return $(node).find("strong").text(); },
			1: function(node, table, cellIndex){ return $(node).find("div").text(); },
			2: function(node, table, cellIndex){ return $(node).find("span").text(); },
			3: function(node, table, cellIndex){ return $(node).find("em").text(); },
			4: function(node, table, cellIndex){ return $(node).find("a").text(); },
			5: function(node, table, cellIndex){ return $(node).find("u").text(); }
		}

	});

});</script>
</head>
<body>

<div id="banner">
	<h1>table<strong>sorter</strong></h1>
	<h2>Dealing with markup inside cells</h2>
	<h3>Flexible client-side table sorting</h3>
	<a href="index.html">Back to documentation</a>
</div>

<div id="main">
	<p class="tip">
		<em>NOTE!</em>
		<ul>
			<li>The textExtraction function setting for each column was added in version 2.0.12 (not part of the original plugin).</li>
			<li>The "First Name" column is sorting by the contents of the &lt;strong&gt; tag (in red).</li>
			<li>Added "table" and "cellIndex" variables to the textExtraction function (v2.1.2).</li>
		</ul>
	</p>

	<h1>Demo</h1>
	<div id="demo"><table class="tablesorter">
	<thead>
		<tr>
			<th>First Name</th>
			<th>Last Name</th>
			<th>Age</th>
			<th>Total</th>
			<th>Discount</th>
			<th>Date</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Mr. <strong>Peter</strong></td>
			<td><div>Parker</div></td>
			<td><span>28</span></td>
			<td><em>$9.99</em></td>
			<td><a href="#">20%</a></td>
			<td><u>Jul 6, 2006 8:14 AM</u></td>
		</tr>
		<tr>
			<td>Dr. <strong>John</strong></td>
			<td><div>Hood</div></td>
			<td><span>33</span></td>
			<td><em>$19.99</em></td>
			<td><a href="#">25%</a></td>
			<td><u>Dec 10, 2002 5:14 AM</u></td>
		</tr>
		<tr>
			<td>Rep <strong>Clark</strong></td>
			<td><div>Kent</div></td>
			<td><span>18</span></td>
			<td><em>$15.89</em></td>
			<td><a href="#">44%</a></td>
			<td><u>Jan 12, 2003 11:14 AM</u></td>
		</tr>
		<tr>
			<td>Rev <strong>Bruce</strong></td>
			<td><div>Almighty</div></td>
			<td><span>45</span></td>
			<td><em>$153.19</em></td>
			<td><a href="#">44%</a></td>
			<td><u>Jan 18, 2001 9:12 AM</u></td>
		</tr>
		<tr>
			<td>Capt <strong>Bruce</strong></td>
			<td><div>Evans</div></td>
			<td><span>22</span></td>
			<td><em>$13.19</em></td>
			<td><a href="#">11%</a></td>
			<td><u>Jan 18, 2007 9:12 AM</u></td>
		</tr>
	</tbody>
</table></div>

	<h1>Javascript</h1>
	<div id="javascript">
		<pre class="prettyprint lang-javascript"></pre>
	</div>
	<h1>HTML</h1>
	<div id="html">
		<pre class="prettyprint lang-html"></pre>
	</div>

<div class="next-up">
	<hr />
	Next up: <a href="example-apply-widget.html">Applying widgets &rsaquo;&rsaquo;</a>
</div>

</div>

</body>
</html>

